#ifndef ALU_H
#define ALU_H

// makes the ALU show debug output
// #define DEBUG 

// ALU opcodes may only be 5 bits
#define ALU_MASK 0x1F

#include <stdio.h>
#include "type.h"
#include "opcode.h"
#include "registers.h"
#include "io.h"

word alu (word a, word b, word aluop);

/*
	 these functions do twos complement arithmetic 
	 regardless of the underlying machine
*/
static word alu_neg (word a);
static word alu_add (word a, word b);
static word alu_sub (word a, word b);
static word alu_abs (word a);

/*
	 multiplication division and modulus depend on the 
	 underlying machine for arithmetic, but manage the 
	 sign manually. Should be portable I hope. 
*/
static word alu_mul (word a, word b);
static word alu_div (word a, word b);
static word alu_mod (word a, word b);

/*
	 utility function called internally
*/
static dword dword_neg (dword a);
static dword dword_add (dword a, dword b);
static dword dword_sub (dword a, dword b);
static dword dword_abs (dword a);

#endif

